package com.lx.oms.controller.manager.impl;

import java.math.BigInteger;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.lx.oms.common.entity.Page;
import com.lx.oms.common.entity.Query;
import com.lx.oms.common.utils.Utils;
import com.lx.oms.controller.dao.AccountMapper;
import com.lx.oms.controller.entity.AccountEntity;
import com.lx.oms.controller.manager.AccountManager;

/**
 * 账户余额
 *
 * @author houzhong
 * @date 2018年10月30日 下午2:02:43
 */
@Component("accountManager")
public class AccountManagerImpl implements AccountManager {

	@Autowired
	private AccountMapper accountMapper;
	

	@Override
	public List<AccountEntity> listAccount(Page<AccountEntity> page, Query search) {
		return accountMapper.listForPage(page, search);
	}

	@Override
	public int saveAccount(AccountEntity tAccount) {
		if (tAccount.getId() == null) {
			tAccount.setId(Utils.id().toString());
		}
		return accountMapper.save(tAccount);
	}

	@Override
	public AccountEntity getAccountById(BigInteger id) {
		AccountEntity tAccount = accountMapper.getObjectById(id);
		return tAccount;
	}

	@Override
	public int updateAccount(AccountEntity tAccount) {
		return accountMapper.update(tAccount);
	}

	@Override
	public int batchRemove(String[] id) {
		int count = accountMapper.batchRemove(id);
		return count;
	}
	
}
